<form method="post" autocomplete="off" action="home.php?mod=spacecp&ac=plugin&id=myrepeats:memcp&pluginop=add">
<input type="hidden" name="formhash" value="{FORMHASH}" />
	<div class="pt10 pl10 mb10 xs2 xg2 cl subshow" href="#adduser">
		<h4 class="z">{lang myrepeats:adduser}</h4>
		<i class="dm-plus-c y"></i>
	</div>
	<div id="adduser" class="setbox sub-box cl">
		<ul class="post_box mt15 cl">
			<!--{if !$singleprem}-->
			<li class="flex-box mli">
				<div class="tit">{lang myrepeats:username}</div>
				<div class="flex-3 input">
					<input name="usernamenew" id="usernamenew" type="text" class="px" value="$username" />
				</div>
				<!--{if $permusers}-->
				<div class="flex-2">
					<select id="userselect" onchange="document.getElementById('usernamenew').value = this.value" class="sort_sel">
						<option value="">{lang myrepeats:select_rrepeats}</option>
						<!--{loop $permusers $user}-->
						<option value="$user">$user</option>
						<!--{/loop}-->
					</select>
				</div>
				<!--{/if}-->
			</li>
			<!--{else}-->
			<li class="flex-box mli">
				<div class="tit">{lang myrepeats:username}</div>
				<!--{if $permusers}-->
				<div class="flex-3">
					<select name="usernamenew" id="usernamenew" class="sort_sel">
						<!--{loop $permusers $user}-->
						<option value="$user"{if $user == $username} selected="selected"{/if}>$user</option>
						<!--{/loop}-->
					</select>
				</div>
				<!--{/if}-->
			</li>
			<!--{/if}-->
			<li class="flex-box mli">
				<div class="tit">{lang myrepeats:password}</div>
				<div class="flex-3 input">
					<input type="password" name="passwordnew" class="px" />
				</div>
			</li>
			<li class="flex-box mli">
				<div class="tit">{lang myrepeats:security_question}</div>
				<div class="flex-3">
					<select name="questionidnew" onchange="if(this.value > 0) {document.getElementById('answernew').style.display='';} else {document.getElementById('answernew').style.display='none';}" class="sort_sel">
						<option value="0">{lang myrepeats:security_question}</option>
						<option value="1">{lang myrepeats:security_question_1}</option>
						<option value="2">{lang myrepeats:security_question_2}</option>
						<option value="3">{lang myrepeats:security_question_3}</option>
						<option value="4">{lang myrepeats:security_question_4}</option>
						<option value="5">{lang myrepeats:security_question_5}</option>
						<option value="6">{lang myrepeats:security_question_6}</option>
						<option value="7">{lang myrepeats:security_question_7}</option>
					</select>
				</div>
			</li>
			<div id="answernew" style="display:none">
			<li class="flex-box mli">
				<div class="tit">{lang myrepeats:security_answer}</div>
				<div class="flex-3 input">
					<input type="text" name="answernew" class="px" class="txt" />
				</div>
			</li>
			</div>
			<li class="flex-box mli">
				<div class="tit">{lang myrepeats:comment}</div>
				<div class="flex-3 input">
					<input type="text" name="commentnew" class="px" size="40" />
				</div>
			</li>
		</ul>
		<button type="submit" name="adduser" class="pn vm" value="yes" ><span>{lang myrepeats:add}</span></button>
	</div>
</form>
<div class="mt10 discuz_x"></div>
<div class="mt10 cl">
<form method="post" autocomplete="off" action="home.php?mod=spacecp&ac=plugin&id=myrepeats:memcp&pluginop=update">
<input type="hidden" name="formhash" value="{FORMHASH}" />
	<!--{if $repeatusers}-->
	<div class="xld xlda">
		<!--{loop $repeatusers $user}-->
		<dl class="bbda b_b cl">
			<dd class="m"><input name="delete[]" type="checkbox" class="pc" value="$user['username']" />{lang myrepeats:delete_check}</dd>
			<dt class="y">
				<p class="xw0"></p>
			</dt>
			<dt><b><!--{if !$user['locked']}--><a href="plugin.php?id=myrepeats:switch&username=$user['usernameenc']&formhash={FORMHASH}">$user['username']</a></b><!--{else}-->$user['username'] ({lang myrepeats:locked})<!--{/if}--></dt>
			<dt><p class="xg1">{lang myrepeats:lastswitch} <!--{if $user['lastswitch']}-->$user['lastswitch']<!--{else}-->{lang myrepeats:nouse}<!--{/if}--></p></dt>
			<dt><input name="comment[{$user['username']}]" class="px" value="$user['comment']" size="40" placeholder="{lang myrepeats:commentrow}" /></dt>
		</dl>
		<!--{/loop}-->
	</div>
	<button type="submit" class="pn" name="updateuser" value="yes" ><span>{lang submit}</span></button>
<!--{/if}-->
</form>
</div>
<script>
	(function() {
		// 初始显示所有.sub-forum元素
		const subForums = document.querySelectorAll('.sub-box');
		subForums.forEach(el => {
			el.style.display = 'none';
		});

		// 为所有.subshow元素绑定点击事件
		const subShows = document.querySelectorAll('.subshow');
		subShows.forEach(btn => {
			btn.addEventListener('click', function() {
				const obj = this;
				// 获取href属性值作为选择器
				const subobjSelector = obj.getAttribute('href');
				const subobj = document.querySelector(subobjSelector);

				if (!subobj) return; // 防止选择器无效

				// 获取计算后的样式来判断显示状态
				const isHidden = getComputedStyle(subobj).display === 'none';

				if (isHidden) {
					subobj.style.display = 'block';
					// 切换i元素的类
					const icon = obj.querySelector('i');
					if (icon) {
						icon.classList.remove('dm-plus-c');
						icon.classList.add('dm-minus-c');
					}
				} else {
					subobj.style.display = 'none';
					// 切换i元素的类
					const icon = obj.querySelector('i');
					if (icon) {
						icon.classList.remove('dm-minus-c');
						icon.classList.add('dm-plus-c');
					}
				}
			});
		});
	})();
</script>